<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>注   册</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
	<script src="js/axios.min.js"></script>
	<script src="js/vue.min.js"></script>
	<script src="js/vote.js"></script>
</head>
<body>
<div id="app">
	<myheader></myheader>
	<div id="register" class="box">
		<h2>新用户注册</h2>
		<div class="content">
			<form method="post" action="reg_success.html">
				<dl>
					<dt>用户ID：</dt>
					<dd><input type="text" disabled class="input-text" name="userId" value=""/></dd>
					<dt>用户名：</dt>
					<dd><input type="text" class="input-text" v-model="user.uname" value=""/></dd>
					<dt>密码：</dt>
					<dd><input type="password" class="input-text" v-model="user.pwd" value=""/></dd>
					<dt>确认密码：</dt>
					<dd><input type="password" class="input-text" v-model="user.repwd" value=""/></dd>
					<dt></dt>
					<dd><input type="submit" @click.prevent="reg" class="input-button" name="submit" value="" /></dd>
				</dl>
			</form>
			<div class="error"></div>
			<div class="error"></div>
		</div>
	</div>
	<div id="footer" class="wrap">
		源辰信息 &copy; 版权所有
	</div>
</div>
<script>
	var v = new Vue({
		el: '#app',
		data:{
			user:{
				uname:"",
				pwd:"",
				repwd:""
			}
		},
		methods:{
			reg(){
				let p = new URLSearchParams();
				p.append("uname",this.user.uname);
				p.append("pwd",this.user.pwd);
				p.append("repwd",this.user.repwd);
				axios.post("RegServlet",p).then(res=>{
					if(res.data.code==1) {
						alert("注册成功");
						location.href = "login.html";
					}else{
						alert(res.data.msg);
					}
				});
			}
		}
	});
</script>
</body>
</html>
